Skip to content

Comments

Add ActorMonitor for tracking actor lifecycle and overflow status#83

Merged
ddrcode merged 1 commit intomaiko-rs:actor-monitorfrom
swaploard:fear--Actor-state-spi-fot-inspection
Feb 21, 2026
Merged

Add ActorMonitor for tracking actor lifecycle and overflow status#83
ddrcode merged 1 commit intomaiko-rs:actor-monitorfrom
swaploard:fear--Actor-state-spi-fot-inspection

Conversation

@swaploard
Copy link
Contributor

This PR implements (#26). A lightweight actor lifecycle introspection mechanism using the existing monitoring layer, without requiring any changes to the supervisor. It enables runtime visibility into actor states such as active, stopped, or overflowing by passively observing lifecycle events. The monitor maintains an internal view of actors and their status, allowing runtime insights while keeping the implementation modular and fully decoupled.

Copy link
Collaborator

@ddrcode ddrcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Thanks again - good work, good tests. I left 3 comments in the code asking for minor changes. Please note that the main branch has changed since your PR, so make sure you rebase, before submitting the new change. Cheers.

/// Called when a new actor is registered in the system.
///
/// Fires once when the actor is spawned and added to the broker registry.
fn on_actor_registered(&self, actor_id: &ActorId) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good and useful, but... it's not plugged anywhere in Maiko's code, so technically it's a dead code. It should be invoked in supervisor when monitoring enabled. That's the only supervisor change needed (unlike the original version of the PR). Alternatively you could catch in in broker.rs.


/// Monitor that tracks actor lifecycle and overflow status.
pub struct ActorMonitor {
inner: Arc<Mutex<ActorMonitorInner>>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monitors run always as a single Tokio task - using Mutex adds unnecessary overhead, you could easily use Rc<RefCell<>> instead. Or - for numeric values - atomics.

See Tracer or Recorder for references.


/// Status returned by `actor_status()`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ActorStatus {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflates lifecycle and overflow history - an actor that overflowed once reports as Overflowing forever - that might be misleading. Sorry if my comment in the previous review was confusing here. What would make more sense would be to have status indicitaing only whether an actor is alive or stopped, and then the overflow_count on top of it. Or - even simplier - is_alive() and overflow_count().

@ddrcode ddrcode added this to the v0.2.x (ergonomics) milestone Feb 21, 2026
@ddrcode ddrcode added the enhancement New feature or request label Feb 21, 2026
@ddrcode ddrcode changed the base branch from main to actor-monitor February 21, 2026 16:49
@ddrcode ddrcode merged commit 91baa44 into maiko-rs:actor-monitor Feb 21, 2026
ddrcode pushed a commit that referenced this pull request Feb 21, 2026
Don't worry about my review, I have merged the PR and applied the changes myself as i want to release new version shortly. All good. Thanks for the contribution!
@ddrcode ddrcode mentioned this pull request Feb 21, 2026
ddrcode added a commit that referenced this pull request Feb 21, 2026
* Add ActorMonitor for tracking actor lifecycle and overflow status (#83)

Don't worry about my review, I have merged the PR and applied the changes myself as i want to release new version shortly. All good. Thanks for the contribution!

* adjustments to proposed pr [#26]

---------

Co-authored-by: Nikhil Patil <nikhil876706@gmail.com>
@ddrcode
Copy link
Collaborator

ddrcode commented Feb 21, 2026

Merged with main in #86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants